﻿@model FairyWorld.Models.User

@{
    ViewBag.Title = "Letters";
    Layout = "~/Views/Shared/UserLayout.cshtml";
}

<script>
    function read(id) {
   //     document.getElementById(id).innerHTML = '已阅读';
        $.post("/User/Letters", { "id": id });
        $("#new" + id).html("");
    }
</script>

<div style="padding-left:10px; padding-right:10px">
<div style="padding-left:25px">
    <h3>私信</h3></div>
    <div class="span8">
    <div class="accordion" id="accordion2">
    @foreach (var item in Model.letters)
    {
        <div class="accordion-group" style="background-color:white">
            <div class="accordion-heading" style="padding-right:20px">
                    @if (item.check == false) { 
                        var newId = "new" + @item.LetterId;
                        <div style="display:inline; float:left; width:10px;color:red" id="@newId"><small>new</small></div>
                    }
                    <div style="display:inline; float:right"><h4><small>@item.time</small></h4></div>
                    <a class="accordion-toggle" style="text-decoration:none" data-toggle="collapse" data-parent="#accordion2" href="#@item.LetterId" onclick="read(@item.LetterId)">
                       <h4>&nbsp;&nbsp;&nbsp;&nbsp;@item.username </h4>
                    </a> 
            </div>
            <div id="@item.LetterId" class="accordion-body collapse"> 
                <div class="accordion-inner">
                    <div style="word-wrap: break-word; word-break: normal;" class="span10">@item.action</div>
                    @if(item.senderId != 0)
                    {
                        <div style="display:block">
                            <form action="LetterResponse">
                                <textarea style="resize:none; height:100px; width:400px" name="responseText"></textarea>
                                <input type="hidden" name="senderId"  value="@item.senderId" />
                                <input type="submit" class="btn" style="vertical-align:bottom; margin-bottom:10px" value="回复"/>
                            </form>
                        </div>
                    }
                </div>         
            </div>  
      </div>
    }
    </div>
    </div>
</div>
